<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <!-- 引入Bootstrap CSS -->
    <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
    <link rel="icon" href="{{ url_for('static', filename='ico.svg') }}" type="image/x-icon">
    <style>
        body {
            background-image: url('/random_image');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            background-attachment: fixed;
        }
        .card {
            background-color: rgba(255, 255, 255, 0.8);
        }
        .toggle-password {
            cursor: pointer;
            position: absolute;
            right: 15px;
            top: 38px;
            color: #999;
        }
        /* 添加以下样式 */
        .version {
            color: #6c757d;
            padding: 10px;
            font-size: 14px;
            text-align: center;
            background-color: rgba(255, 255, 255, 0.8);
            position: fixed;
            bottom: 0;
            width: 100%;
        }
        .version p {
            margin: 0;
        }
    </style>
</head>
<body>
    <!-- 显示闪现消息 -->
    {% with messages = get_flashed_messages(with_categories=true) %}
        {% if messages %}
            <div class="container mt-3">
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                        {{ message }}
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="关闭"></button>
                    </div>
                {% endfor %}
            </div>
        {% endif %}
    {% endwith %}
    <div class="container d-flex justify-content-center align-items-center" style="min-height: 80vh;">
        <div class="card p-4" style="width: 400px; position: relative;">
            <div class="text-center">
                <!-- Logo -->
                <img src="{{ url_for('static', filename='logo.png') }}" alt="Logo" style="max-width: 100px;">
                <h3>登录</h3>
            </div>
            <form method="post" action="{{ url_for('login') }}">
                <div class="mb-3 position-relative">
                    <label for="username" class="form-label">用户名</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="输入用户名" required>
                </div>
                <div class="mb-3 position-relative">
                    <label for="password" class="form-label">密码</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="输入密码" required>
                    <span toggle="#password" class="toggle-password" onclick="togglePassword('password')">显示</span>
                </div>
                <button type="submit" class="btn btn-primary w-100">登录</button>
                <div class="text-center mt-3">
                    <!-- 忘记密码链接 -->
                    <p><a href="{{ url_for('forgot_password') }}">忘记密码？</a></p>
                </div>
            </form>
        </div>
    </div>

    <div class="version">
        <p>项目名称：<strong>alist-strm</strong></p>
        <p>作者：<strong><a href="https://www.tefuir0829.cn" target="_blank">tefuir</a></strong></p>
        <p>版本：{{ g.local_version }}</p>
    </div>
    <!-- 引入Bootstrap JS -->
    <script src="{{ url_for('static', filename='js/bootstrap.bundle.min.js') }}"></script>
    <script>
        function togglePassword(id) {
            var input = document.getElementById(id);
            var toggle = input.nextElementSibling;
            if (input.type === "password") {
                input.type = "text";
                toggle.textContent = "隐藏";
            } else {
                input.type = "password";
                toggle.textContent = "显示";
            }
        }
    </script>
</body>
</html>
